clear all 
set more off
cd "/Users/yasenov/Dropbox/mariel_boatlift/jhr_version/jhr_figures"
global folder /Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/
set scheme s1color

use "/Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/raw_may_cps.dta"
replace earnwt = earnwt / 100 
replace weight = weight / 100 
append using "/Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/raw_org_cps_mariel.dta"

global folder /Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/
merge m:1 cmsarank pmsarank using $folder/crosswalk.dta, nogen update 
merge m:1 cmsarank msafips using $folder/crosswalk.dta, nogen update 
merge m:m cmsarank using $folder/crosswalk.dta, nogen update   // no updates are made for cmsa's with many smsa areas.

drop if earnwt < 0 | weight < 0
keep if smsarank == 26

gen low_skilled = gradeat < 12
gen cuban = (ethnic == 5)
gen one = 1

preserve
collapse (sum) one [pw=weight], by(year)
sort year
rename one pop_org
tempfile edno
save `edno'
restore

preserve
keep if age >= 19 & age <= 65
*keep if cuban == 0
keep if low_skilled == 1
drop if (ftpt79 == 0 & year <= 1988) | (ftpt89 ==1 & year > 1988) 
keep if classer == 1 | classer == 2 

collapse (sum) one [pw=weight], by(year)
sort year
rename one hsd_org
tempfile dve
save `dve'
restore

preserve
keep if cuban == 0
collapse (sum) one [pw=weight], by(year)
sort year
rename one pop_noncuban_org
tempfile tri
save `tri'
restore

preserve
keep if age >= 19 & age <= 65
keep if cuban == 0
keep if low_skilled == 1
drop if (ftpt79 == 0 & year <= 1988) | (ftpt89 ==1 & year > 1988) 
keep if classer == 1 | classer == 2 

collapse (sum) one [pw=weight], by(year)
sort year
rename one hsd_noncuban_org
tempfile chetiri
save `chetiri'
restore

preserve
gen hisp = (ethnic != 8 & ethnic != 5)
keep if age >= 19 & age <= 65
keep if hisp == 0
keep if low_skilled == 1
drop if (ftpt79 == 0 & year <= 1988) | (ftpt89 ==1 & year > 1988) 
keep if classer == 1 | classer == 2 

collapse (sum) one [pw=weight], by(year)
sort year
rename one hsd_nonhisp_org
tempfile pet
save `pet'
restore

preserve
keep if age >= 19 & age <= 65
keep if cuban == 1
keep if low_skilled == 1
drop if (ftpt79 == 0 & year <= 1988) | (ftpt89 ==1 & year > 1988) 
keep if classer == 1 | classer == 2 

collapse (sum) one [pw=weight], by(year)
sort year
rename one hsd_cuban_org
tempfile shest
save `shest'
restore

clear
use `edno'
merge 1:1 year using `dve', nogen
merge 1:1 year using `tri', nogen
merge 1:1 year using `chetiri', nogen
merge 1:1 year using `pet', nogen
merge 1:1 year using `shest', nogen

**********************
**********************
**********************

gen share_hsd_org = hsd_org / pop_org
gen share_noncuban_hsd_org = hsd_noncuban_org / pop_org
gen share_nonhisp_hsd_org = hsd_nonhisp_org / pop_org
gen share_cuban_hsd_org = hsd_cuban_org / pop_org

replace pop_org = pop_org / 1000000
replace hsd_org = hsd_org / 1000000
replace pop_noncuban_org = pop_noncuban_org / 1000000
replace hsd_noncuban_org = hsd_noncuban_org / 1000000

drop if year > 1985

/* graphing shares */
twoway (line share_hsd_org year, lcolor(black)  lwidth(medthick)) ///
	(line share_noncuban_hsd_org year, lcolor(gs3) lpatter(longdash) lwidth(medthick)) ///
	(line share_cuban_hsd_org year, lcolor(gs4) lpattern(dot) lwidth(medthick)), ///
	xline(1979, lcolor(black) lpattern(dash)) ///
	xtitle("") ytitle("") ///
	ylabel(0.05(.02).15) ///
	xlabel(1973 "1973" 1974 "74" 1975 "75" 1976 "76" 1977 "77" 1978 "78" 1979 `""79" "Pre""' ///
	1980 `""80" "Shock""' 1981 `""81" "Post""' 1982 "82" 1983 "83" 1984 "84" 1985 "85") ///
	legend(label(1 "All") label(2 "Non-Cuban") label(3 "Cuban") r(1))
 	
graph export "jhr_figa1.pdf", replace
